from datetime import datetime

from sqlalchemy import Column, Integer, String, DateTime

from api.database.database import Base, engine


class SampleEntity(Base):
    __tablename__ = 'sample'
    id = Column(Integer, primary_key=True, comment="ID")
    sample_name = Column(String, unique=True, index=True, comment="样本名字", nullable=False)
    path = Column(String, comment="存储路径", nullable=False)
    create_time = Column(DateTime,nullable=False)
    user_name = Column(String, comment="用户名", nullable=False)


# 用户训练的模型
class ModelEntity(Base):
    __tablename__ = 'models'
    id = Column(Integer, primary_key=True, comment="ID")
    premodel_name = Column(String, unique=True, index=True, comment="训练的模型名字" , nullable=False)
    path = Column(String, comment="存储路径" , nullable=False)
    create_time = Column(DateTime, default=datetime.now, nullable=False)
    user_name = Column(String, comment="用户名")


class UserEntity(Base):
    __tablename__ = 'Users'
    id = Column(Integer, primary_key=True, comment="ID")


class StandradLibEntity(Base):
    __tablename__ = 'standard'
    id = Column(Integer, primary_key=True, comment="ID")
    user_name = Column(String, comment="用户名")
    path = Column(String, comment="标准库路径", nullable=False)
    name = Column(String, comment="标准库名称", nullable=False)
    desc = Column(String, comment="标准库描述")
    create_time = Column(DateTime, default=datetime.now)


# 如果表不存在则创建表;
Base.metadata.create_all(engine)

